<?php
/**
 * Created by PhpStorm.
 * User: River
 * Email: river0428@gmail.com
 * Date: 2018/6/11
 * Time: 上午10:18
 */

// 登录注册

Route::prefix('admin')->name('admin_')->group(function() {
    Route::get('/login', 'LoginController@index')->name('login');
    /*
    Route::get('/login',function(){
        return redirect('https://mcp.jiayouhui360.com/admin/');
    })->name('login');
    */
    Route::post('/send_code','LoginController@sendCode')->name('send_code');
    Route::post('/login', 'LoginController@login');
    Route::get('/logout', 'LoginController@logout')->name('logout');

    // 退出登录
    Route::get('/logout', 'LoginController@logout');
});

Route::middleware('admin.auth')->group(function() {

    // 首页
    Route::get('/admin', 'IndexController@index')->name('admin_home');

    // 管理员账号
    Route::get('/admin/user', 'AdminUserController@index')->name('admin_user');
    Route::get('/admin/user_all', 'AdminUserController@all')->name('get_admin_user');
    Route::post('/admin/user', 'AdminUserController@store')->name('post_admin_user');
    Route::put('/admin/user/{id}', 'AdminUserController@update')->name('put_admin_user');
    Route::delete('/admin/user/{id}', 'AdminUserController@destroy')->name('delete_admin_user');
    Route::put('/admin/user/{id}/restore', 'AdminUserController@restore')->name('put_admin_user_restore');

    // 角色
    Route::get('/admin/role', 'AdminRoleController@index')->name('admin_role');
    Route::get('/admin/role_all', 'AdminRoleController@all')->name('get_admin_role_all');
    Route::post('/admin/role', 'AdminRoleController@store')->name('post_admin_role');
    Route::put('/admin/role/{id}', 'AdminRoleController@update')->name('put_admin_role');
    Route::delete('/admin/role/{id}', 'AdminRoleController@destroy')->name('delete_admin_role');

    // 后台可访问资源
    Route::get('/admin/resource', 'AdminRoleController@resource')->name('resource');

    // 修改密码
    Route::post('/admin/change_password', 'LoginController@changePassword')->name('post_password');
});